package com.tjx.controller;


import com.tjx.common.Result;
import com.tjx.entity.Faq;
import com.tjx.mapper.FaqMapper;
import com.tjx.service.IFaqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 常见问题表 前端控制器
 * </p>
 *
 * @author tjx
 * @since 2025-10-29
 */
@RestController
@RequestMapping("/faq")
public class FaqController {

    @Autowired
    private IFaqService faqService;

    /**
     * 查询所有常见问题
     */
    @RequestMapping("/faqQueryAll")
    public Result<List<Faq>> faqQueryAll() {
        List<Faq> faqList = faqService.faqQueryAll();
        if(faqList != null){
            return Result.ok(faqList);
        }
        return Result.fail();
    }

    /**
     * 新增常见问题
     */
    @RequestMapping("/faqAdd")
    public Result<Faq> faqAdd(@RequestBody Faq faq) {
        Integer row = faqService.faqAdd(faq);
        if(row > 0){
            return Result.ok();
        }
        return Result.fail();
    }

    /**
     * 修改常见问题
     */
    @RequestMapping("/faqUpdate")
    public Result<Faq> faqUpdate(@RequestBody Faq faq) {
        Integer row = faqService.faqUpdate(faq);
        if(row > 0){
            return Result.ok();
        }
        return Result.fail();
    }

    /**
     * 删除常见问题
     */
    @RequestMapping("/faqDelete")
    public Result<Faq> faqDelete(@RequestBody Faq faq) {
        Integer row = faqService.faqDelete(faq);
        if(row > 0){
            return Result.ok();
        }
        return Result.fail();
    }

}
